// Copyright (C) 2025 Kumo inc.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//

#include <clocale>
#include <cstdio>

#include "test.hpp"

namespace rothar
{
   struct file_content
      : seq< ROTHAR_PEGTL_STRING( "dummy content" ), eol, discard >
   {};

   struct file_grammar
      : seq< rep_min_max< 11, 11, file_content >, eof >
   {};

   void unit_test()
   {
      const char* const filename = "tests/file_data.txt";
#if defined( _MSC_VER )
      std::FILE* stream;
      ::fopen_s( &stream, filename, "rb" );
#else
      std::FILE* stream = std::fopen( filename, "rb" );
#endif
      ROTHAR_PEGTL_TEST_ASSERT( stream != nullptr );
      ROTHAR_PEGTL_TEST_ASSERT( parse< file_grammar >( cstream_input( stream, 16, filename ) ) );
      std::fclose( stream );
   }

}  // namespace rothar

#include "main.hpp"
